package coml.jiyun.hp.reviewtopic;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import coml.jiyun.hp.reviewtopic.ui.activity.HomeActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    /**
     * 跳过
     */
    private Button mMainBtnJump;
    private TextView mMainTv;
    private ImageView mMainImg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        mMainBtnJump = (Button) findViewById(R.id.main_btn_jump);
        mMainTv = (TextView) findViewById(R.id.main_Tv);
        mMainImg = (ImageView) findViewById(R.id.main_img);
        mMainBtnJump.setOnClickListener(this);

        Animation animation = AnimationUtils.loadAnimation(this, R.anim.set3);
        mMainImg.startAnimation(animation);
        new CountDownTimer(6000, 1000) {

            @Override
            public void onTick(long millisUntilFinished) {
                mMainTv.setText("倒计时:" + millisUntilFinished / 1000 + "s");
            }

            @Override
            public void onFinish() {
                if (!mMainBtnJump.isDirty()){
                startActivity(new Intent(MainActivity.this, HomeActivity.class));
                }
                return;
            }
        }.start();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
            case R.id.main_btn_jump:
                startActivity(new Intent(MainActivity.this, HomeActivity.class));
                break;
        }
    }
}